'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const db = uniCloud.database({})
	const shop = db.collection("db_user_collect")
	let dd;
	await shop.where({
		item_id: event.item_id,
		uid: event.uid
	}).get().then(res => {
		dd = res.data
		console.log(res.data)
	})

	if (dd.length > 0) {
		await shop.where({
			item_id: event.item_id,
			uid: event.uid,
		}).remove()
	} else {
		await shop.add({
			item_id: event.item_id,
			uid: event.uid,
		})
	}

	//返回数据给客户端
	return dd
};